package com.ruoyi.cms.api;

import com.ruoyi.cms.domain.Category;
import com.ruoyi.cms.service.ICategoryService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Controller
@RequestMapping("/api/category")
public class CategoryApiController extends BaseController {

    @Autowired
    private ICategoryService categoryService;

    /**
     * 查询栏目分类树列表
     */
//    @RequiresPermissions("cms:category:list")
    @RequestMapping("/list")
    @ResponseBody
    public AjaxResult list(Category category) {

        List<Category> list = categoryService.selectCategoryList(category);
        return AjaxResult.success("success", list);

    }

    /**
     * 查询栏目分类树列表
     */
    @RequestMapping("/listTree")
    @ResponseBody
    public AjaxResult listTree(Category category)
    {
        List<Category> list = categoryService.selectNavCategories(category);
        return AjaxResult.success("success", list);
    }

    @RequestMapping("/byid")
    @ResponseBody
    public AjaxResult byid(Long id) {

        Category category = categoryService.selectCategoryById(id);
        return AjaxResult.success("success", category);

    }

}
